<template>
  <!-- 订单信息 -->
  <ContentWrap :style="`height: ${contentHeight}px`">
    <div class="routeHeader">
      <el-button
        @click="goBack"
      >
        关闭
      </el-button>
    </div>
    <el-scrollbar :max-height="`${contentHeight - 73}px`">
      <el-table border v-loading="loading" :data="list">
        <el-table-column label="订单号" align="left" prop="orderNumber" min-width="200px" />
        <el-table-column label="产品编号" align="left" prop="productNumber" min-width="200px" />
        <el-table-column label="产品名称" align="left" prop="productName" min-width="200px" />
        <el-table-column label="产品规格" align="left" prop="productStandard" min-width="200px" />
        <el-table-column label="单位" align="left" prop="partUnit" min-width="200px" />
        <el-table-column label="订单数量" align="left" prop="orderQuantity" min-width="200px" />
        <el-table-column label="发货日期" align="left" prop="deliveryDate" min-width="200px" />
        <el-table-column label="备注" align="left" prop="remark" min-width="200px" />
        <el-table-column label="创建人" align="left" prop="creatorName" min-width="200px" />
        <el-table-column label="创建时间" align="left" prop="createTime" min-width="200px" >
          <template #default="scope">
            <div>
              {{ formatDate(scope.row.createTime) }}
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-scrollbar>
  </ContentWrap>
</template>
<script lang="ts" setup>
import * as SalesMaterialManagementApi from '@/api/orderManagement/salesMaterialManagement'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { formatDate } from '@/utils/formatTime'
const { currentRoute, back } = useRouter()

const loading = ref(false)  //表单加载中
const list = ref<any>([])  //订单信息

const contentHeight = ref(0)

// 返回
const tagsViewStore = useTagsViewStore()
const goBack = () => {
  //获取当前路由并删除tagView
  tagsViewStore.delView(currentRoute.value)
  back()
}

const getList = async (id) => {
  const res = await SalesMaterialManagementApi.getSalesMaterialManagementDetail(id)
  list.value = res.list
}

/** 初始化 **/
onMounted(() => {
  contentHeight.value = document.body.clientHeight - 125
  getList(currentRoute.value.query.id)
})
</script>